import React, { Component } from 'react'
import UserModel from '../interface/userinterface'
interface IProps {
    list: Array<UserModel>,
    delUserById: (id: number | undefined) => void
}
export default class ListUser extends Component<IProps, any> {
    render() {
        return (
            <div className="table">
                <div className="tr">
                    <div className="td">编号</div>
                    <div className="td">用户名</div>
                    <div className="td">密码</div>
                    <div className="td">操作</div>
                </div>
                {this.props.list.map((item) => {
                    return (
                        <div className="tr" key={item.id}>
                            <div className="td">{item.id}</div>
                            <div className="td">{item.username}</div>
                            <div className="td">{item.userpwd}</div>
                            <div
                                className="td"
                                onClick={() => {
                                    this.props.delUserById(item.id);
                                }}
                            >
                                删除
                            </div>
                        </div>
                    );
                })}
            </div>
        )
    }
}
